//
//  ViewOfHeader.m
//  Car
//
//  Created by apple on 15/9/21.
//  Copyright (c) 2015年 朱鸿儒. All rights reserved.
//

#import "ViewOfHeader.h"
@implementation ViewOfHeader

- (instancetype)initWithFrame:(CGRect)frame name:(NSString *)name {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self justBigView];
        
        //  设置图片
        [self setUpPhotoViewWithnName:name];
        //  设置图片标题
        [self setUpNameAndRegister];
        //  设置bigView 下面的圆形
        [self SetUpOtherLabel];
        
        
    }
    
    
    return self;
}


//  放照片的button
- (void)setUpPhotoViewWithnName:(NSString *)name {
    
    self.photoButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.photoButton.frame = CGRectMake(20, 15, 80, 80);
    //   设置图片
    [self.photoButton setBackgroundImage:[UIImage imageNamed:@"user1"] forState:UIControlStateNormal];
    //  圆角
    self.photoButton.layer.cornerRadius = 40;
    self.photoButton.layer.masksToBounds = YES;
    //  边框
    self.photoButton.layer.borderWidth = 2;
    self.photoButton.layer.borderColor = [[UIColor whiteColor] CGColor];
    
    //  self.photoButton.backgroundColor = [UIColor redColor];
    
    [self.bigView addSubview:self.photoButton];

}


//  显示名字的button
- (void)setUpNameAndRegister {
    
    self.nameAndRegisterButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.nameAndRegisterButton.frame = CGRectMake(self.photoButton.frame.origin.x + self.photoButton.frame.size.width, self.photoButton.frame.origin.y + self.photoButton.frame.size.height / 2 - 20, 150, 40);
    
  //  self.nameAndRegisterButton.layer.masksToBounds = YES;
  //  self.nameAndRegisterButton.layer.cornerRadius = 20;
    
   // self.nameAndRegisterButton.layer.borderWidth = 2;

   // self.nameAndRegisterLabel.backgroundColor = [UIColor redColor];

    
    self.nameAndRegisterButton.tintColor = [UIColor whiteColor];
    
    [self.bigView addSubview:self.nameAndRegisterButton];
    
    
}

- (void)justBigView {
    
    self.bigView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kWidth, 180)];
    self.bigView.backgroundColor = [UIColor colorWithRed:51/255.0f green:161/255.0f blue:201/255.0f alpha:0.8f];
    
    
    //  渐变效果
    CGFloat a1 = 1.0;
    for (double i = 0; i < 460; i++) {
        UIView *view1=[[UIView alloc]initWithFrame:CGRectMake(i, 0, 1, 180)];
        a1 = i / 460;
        view1.backgroundColor=[UIColor colorWithRed:51/255.0f - a1 green:161/255.0f - a1 blue:201/255.0f - a1 alpha:1.0];
        
        [self.bigView addSubview:view1];
    }
    
    
    [self addSubview:self.bigView];
    
}


- (void)SetUpOtherLabel {
    
//    for (int a = 0; a < 5; a++) {
//        self.roundLabel = [[UILabel alloc] initWithFrame:CGRectMake(kWidth / 5 * a, 10 + 180, 70, 70)];
//        self.roundLabel.backgroundColor = [UIColor redColor];
//        
//        //  圆角
//        self.roundLabel.layer.cornerRadius = 35;
//        self.roundLabel.layer.masksToBounds = YES;
//        
//        [self.bigView addSubview:self.roundLabel];
//    }
    
//    for (int i  = 0; i < 5; i++) {
//        self.squareLabel = [[UILabel alloc] initWithFrame:CGRectMake(0 + i * kWidth / 5, self.bigView.frame.size.height - 70, kWidth / 5, 70)];
////        self.squareLabel.backgroundColor = [UIColor colorWithRed:51/255.0f green:161/255.0f blue:201/255.0f alpha:1.0];
//        
////        self.squareLabel.layer.masksToBounds = YES;
////        self.squareLabel.layer.cornerRadius = 35;
//        
//        
//        [self.bigView addSubview:self.squareLabel];
//
//
//
//        self.lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.squareLabel.frame.origin.x + kWidth/5, self.squareLabel.frame.origin.y + 10, 2, 50)];
//        
//        self.lineLabel.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.5];
//        
//        self.lineLabel.layer.cornerRadius = 1;
//        self.lineLabel.layer.masksToBounds = YES;
//        
//        [self.bigView addSubview:self.lineLabel];
//        
//        
//    }
    
        
}

















@end
